//
//  YYGuideScrollView.m
//  PaasLocal
//
//  Created by 余意 on 2018/7/3.
//  Copyright © 2018年 余意. All rights reserved.
//

#import "YYGuideScrollView.h"

@implementation YYGuideScrollView

{
    NSArray * _imageNameArray;
}

- (void)dealloc
{
    NSLog(@"%s",__func__);
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setup];
    }
    return self;
}

- (void)setup
{
    _imageNameArray = @[@"",@"",@""];
    NSInteger count = _imageNameArray.count;
    
    self.pagingEnabled = YES;
    self.scrollEnabled = YES;
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    
    self.contentSize = CGSizeMake(width * count , height);
    
    for (NSInteger i = 0 ; i < count ; i ++)
    {
        UIImageView * iv = [UIImageView new];
        iv.frame = CGRectMake(width * i, 0, width, height);
        [self addSubview:iv];
        
        if (i == count - 1)
        {
            iv.userInteractionEnabled = YES;
            UITapGestureRecognizer * ges = [UITapGestureRecognizer new];
            [ges addTarget:self action:@selector(imageViewClick:)];
            [iv addGestureRecognizer:ges];
        }
    }
}

- (void)imageViewClick:(UITapGestureRecognizer *)sender
{
    [self removeFromSuperview];
}

@end
